import { HttpClient } from "@angular/common/http";
import { ClusterComponent } from "../../../../riskCluster/cluster.component";
import { ClusterModelWrapper } from "../../../../riskCluster/cluster.model";
import { ChartRiskFrameworkModel } from "./models/chartRiskFramework.model";
import { ChartIssueExposureModel, ChartIssueExposureSummaryModel } from "./models/chartIssueExposure.model";
import { ChartRiskManagementModel } from "./models/chartRiskManagement.model";
import { ChangeDetectorRef } from "@angular/core";
import { ClusterService } from "../../../../riskCluster/cluster.service";


/**
 * overview model
 */
export class OverviewModel extends ClusterComponent {
    public lastUpdate: string;

    public riskRating: number;

    public riskClusters: ClusterModelWrapper[];

    public currentClusterCode: string;

    public currentClusterName: string;

    public riskFramework: ChartRiskFrameworkModel[];

    public riskIssueExposure: ChartIssueExposureModel[];

    public riskIssueExposureSummary: ChartIssueExposureSummaryModel[];

    public riskManagement: ChartRiskManagementModel[];

    public isCore = false;

    get addPlus(): boolean {
        return this.maxRating == 20 ? true : false;
    }

    //baseline, materialissue, idiosyncratic)
    public meiType: string;

    constructor(private modelRef: ChangeDetectorRef) {
        super(modelRef);
    }

    public errorReset() {
        this.lastUpdate = undefined;
        this.riskRating = undefined;
        this.riskClusters = [];
        this.currentClusterCode = undefined;
        this.currentClusterName = undefined;
        this.riskFramework = undefined;
        this.riskIssueExposure = undefined;
        this.riskIssueExposureSummary = undefined;
        this.riskManagement = undefined;
        this.meiType = undefined;
    }

    get maxRating() {
        return this.riskClusters ? this.riskClusters[this.riskClusters.length - 1].topInterval : 100;
    }
}